package myself.a001算法入门;

import myself.a000util.Constants;
import myself.a000util.Logarithm;

/**
 * @author 叶之越
 * Description
 * Date 2021/1/20
 * Time 20:38
 * Mail 739153436@qq.com
 */
public class InsertionSort {
    public static void main(String[] args) {
        Logarithm.check(InsertionSort.class, Constants.normalSort, true);
    }

    public void sort(int[] arr) {
        for (int i = 1; i < arr.length; i++) {
            for (int j = i; j > 0 && (arr[j] < arr[j - 1]); j--) {
                int temp = arr[j];
                arr[j] = arr[j - 1];
                arr[j - 1] = temp;
            }
        }
    }
}
